<?php
namespace App;

use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManager;

/**
 * Class singleton for keeping application global variables
 */
class Globals
{
    /**
     *
     * @var Globals
     */
    private static $_instance;

    /**
     *
     * @var EntityManager
     */
    private $_entity_manager;

    /**
     *
     * @var Collection
     */
    private $_config;

    /**
     * Singleton realisation
     * @return Globals
     */
    public static function getInstance()
    {
        if( is_null(self::$_instance) )
            self::$_instance = new Globals;
        return self::$_instance;
    }

    /**
     * Alias for getInstance() (short version)
     * @return Globals
     */
    public static function init()
    {
        return self::getInstance();
    }

    /**
     *
     * @param Collection $config
     */
    public function setConfig(Collection $config)
    {
        $this->_config = $config;
    }

    /**
     *
     * @return Collection
     */
    public function getConfig()
    {
        return $this->_config;
    }

    /**
     *
     * @param EntityManager $config
     */
    public function setEntityManager(EntityManager $config)
    {
        $this->_entity_manager = $config;
    }

    /**
     *
     * @return EntityManager
     */
    public function getEntityManager()
    {
        return $this->_entity_manager;
    }
}

